package com.hecate.user.webapi.controller;

import com.hecate.common.response.HecateResponse;
import com.hecate.user.api.req.permissionresource.DeletePermissionResourceByBidRequest;
import com.hecate.user.api.req.permissionresource.FindPermissionResourceByBidRequest;
import com.hecate.user.api.req.permissionresource.SavePermissionResourceRequest;
import com.hecate.user.api.req.permissionresource.UpdatePermissionResourceRequest;
import com.hecate.user.dto.permissionresource.DeletePermissionResourceByBidDTO;
import com.hecate.user.dto.permissionresource.FindPermissionResourceByBidDTO;
import com.hecate.user.dto.permissionresource.SavePermissionResourceDTO;
import com.hecate.user.dto.permissionresource.UpdatePermissionResourceDTO;
import com.hecate.user.service.PermissionResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 黄星星
 * @date 2020-12-05
 */
@Api(value = "权限资源接口", tags = { "权限资源接口" })
@RestController
public class PermissionResourceController {

    @Autowired
    private PermissionResourceService permissionResourceService;

    @ApiOperation("新增权限资源")
    @PostMapping("/permissionResource/savePermissionResource")
    public HecateResponse<SavePermissionResourceDTO> savePermissionResource(@RequestBody SavePermissionResourceRequest savePermissionResourceRequest){
        HecateResponse<SavePermissionResourceDTO> savePermissionResourceDTOHecateResponse = permissionResourceService.savePermissionResource(savePermissionResourceRequest);
        return savePermissionResourceDTOHecateResponse;
    }

    @ApiOperation("更新权限资源")
    @PostMapping("/permissionResource/updatePermissionResource")
    public HecateResponse<UpdatePermissionResourceDTO> updatePermissionResource(@RequestBody UpdatePermissionResourceRequest updatePermissionResourceRequest){
        return permissionResourceService.updatePermissionResource(updatePermissionResourceRequest);
    }

    @ApiOperation("删除权限资源")
    @PostMapping("/permissionResource/deletePermissionResource")
    public HecateResponse<DeletePermissionResourceByBidDTO> deletePermissionResourceByBid(@RequestBody DeletePermissionResourceByBidRequest deletePermissionResourceByBidRequest){
        return permissionResourceService.deletePermissionResourceByBid(deletePermissionResourceByBidRequest);
    }

    @ApiOperation("根据bid查看权限资源")
    @PostMapping("/permissionResource/findPermissionResourceByBid")
    public HecateResponse<FindPermissionResourceByBidDTO> findPermissionResourceByBid(@RequestBody FindPermissionResourceByBidRequest findPermissionResourceByBidRequest){
        return permissionResourceService.findPermissionResourceByBid(findPermissionResourceByBidRequest);
    }
}
